<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>失物招领平台首页</title>
<script type="text/javascript" src="../js/jquery.js"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../css/bootstrap.css" />
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/main.css" />
<script type="text/javascript" src="../js/bootstrap.js"></script>
<script type="text/javascript" src="../js/scrollspy.js"></script>
<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript" src="../js/login.js"></script>
</head>

<body>
	<!--
			标题和图片轮播
		-->
	<div class="container">
		<div class="title row">
			<div class="col-md-12">
				<ol class="titlecontent breadcrumb">
					<li><a href="#">徐州工程学院失物招领平台</a></li>
					<li class="active">首页</li>
					<a href="Register.jsp" id="register" class="login dropdown-toggle">注册
					</a>

					<a href="#" id="login" class="login dropdown-toggle"
						data-toggle="modal" data-target="#loginmodal"
						style="margin-right: 20px;">登录 </a>

				</ol>
			</div>
			<div class="col-md-12">
				<div id="myCarousel" class="carousel slide" data-ride="carousel">
					<!-- 轮播（Carousel）指标 -->
					<ol class="carousel-indicators">
						<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
						<li data-target="#myCarousel" data-slide-to="1"></li>
						<li data-target="#myCarousel" data-slide-to="2"></li>
					</ol>
					<!-- 轮播（Carousel）项目 -->
					<div class="carousel-inner">
						<div class="item active">
							<img src="../img/1.jpg" alt="中心校区">
						</div>
						<div class="item">
							<img src="../img/2.jpg" alt="中心校区北门">
						</div>
						<div class="item">
							<img src="../img/3.jpg" alt="图书馆">
						</div>
					</div>
					<!-- 轮播（Carousel）导航 -->
					<a class="carousel-control left" href="#myCarousel"
						data-slide="prev">&lsaquo; </a> <a class="carousel-control right"
						href="#myCarousel" data-slide="next">&rsaquo; </a>
				</div>
			</div>

			<!--
            	作者：1462859532@qq.com
            	时间：2017-03-28
            	描述：导航条
           -->
			<div class="col-md-12">
				<nav class="navbar navbar-default">
				<div class="container-fluid">
					<div class="navbar-header">
						<a class="navbar-brand active" href="#"><span
							class="glyphicon glyphicon-home" aria-hidden="true"></span>主页</a>
					</div>
					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">
							<li class=""><a href="Losing.jsp"><span
									class="glyphicon glyphicon-pencil" aria-hidden="true"></span>失物信息</a>
							</li>
							<li class=""><a href="Finding.jsp"><span
									class="glyphicon glyphicon-search" aria-hidden="true"></span>寻物信息</a>
							</li>
							<li class=""><a href="Guidence.jsp"><span
									class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>使用指南</a>
							</li>
							
						</ul>
					</div>
				</div>
				</nav>
			</div>
			<!--
                	作者：1462859532@qq.com
                	时间：2017-03-28
                	描述：标签页
                -->
			<div class="col-md-12">
				<div class="col-md-6">
					<ul id="myTab" class="nav nav-tabs">
						<li class="active"><a href="#losing" data-toggle="tab"> <span
								class="glyphicon glyphicon-pencil" aria-hidden="true"></span>寻物信息
						</a></li>
						<li><a href="#finding" data-toggle="tab"> <span
								class="glyphicon glyphicon-search" aria-hidden="true"></span>招领信息
						</a></li>

					</ul>
					<div id="myTabContent" class="tab-content">
						<div class="tab-pane fade in active" id="losing">
							<div class="panel panel-default">
								<!-- Default panel contents -->
								<!-- Table -->
								<table class="losingtab table table-hover" id="losingitem">

								</table>
								<nav aria-label="Page navigation" style="margin: 0 auto;">
								<ul class="pagination">
									<li id="losingingpagevalue" style="display: none"></li>
									<li id="losingingpagecount" style="display: none"></li>
									<li><a href="#" id="losingfirst">首页</a></li>
									<li><a href="#" id="losingprev">上一页</a></li>
									<li><a href="#" id="losingnext">下一页</a></li>
									<li><a href="#" id="losinglast">尾页</a></li>


								</ul>
								</nav>
							</div>
						</div>
						<div class="tab-pane fade " id="finding">
						    <div class="panel panel-default">
							<table class="findingtab table table-hover" id="findingitem">

							</table>
							<nav aria-label="Page navigation" style="margin: 0 auto;">
							<ul class="pagination">
								<li id="findingpagevalue" style="display: none"></li>
								<li id="findingpagecount" style="display: none"></li>
								<li><a href="#" id="itemfirst">首页</a></li>
								<li><a href="#" id="itemprev">上一页</a></li>
								<li><a href="#" id="itemnext">下一页</a></li>
								<li><a href="#" id="itemlast">尾页</a></li>
							</ul>
							</nav>
							</div>
						</div>
					</div>
				</div>
				<div class="col-md-6">
					<div class="col-md-12">
						<!--
                        	作者：1462859532@qq.com
                        	时间：2017-03-28
                        	描述：公告面板
                      -->
						<div class="panel panel-default">
							<div class="panel-heading">
								<h3 class="panel-title" style="text-align: center;">公告栏</h3>
							</div>
							<div class="panel-body" id="titlecontent" style="height:400px"></div>
						</div>
					</div>
					
				</div>
			</div>
		</div>
	</div>
	<div class="container-fluid" style="text-align: center;">
		丁鑫版权所有@copyright</div>
	<!--
        	作者：1462859532@qq.com
        	时间：2017-03-28
        	描述：登录模态框
        -->
	<div class="modal fade" id="loginmodal" tabindex="-1" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">招领平台登录</h4>
				</div>
				<div class="modal-body">
					<div role="form">
						<div class="form-group">
							<!--
                                	作者：1462859532@qq.com
                                	时间：2017-03-28
                                	描述：可以在上面做个表单验证
                                -->
							<label for="inputEmail3" class="control-label">用户名</label> <input
								type="text" name="UserId" id="input" class="form-control"
								value="" required="required" pattern="" title=""
								placeholder="用户名">
						</div>
						<div class="form-group">
							<label for="inputPassword3" class="control-label">用户密码</label> <input
								type="password" name="password" class="form-control" id="password"
								placeholder="密码">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<div style="float: left;">
						<a href="#" id="register" class="login dropdown-toggle">忘记密码？
						</a>
					</div>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="btnsubmit">登录</button>
				</div>
			</div>
			<!--模态框关闭-->
			<script type="text/javascript">
				      $(function(){
				    	  $('#myTab li:eq(1) a').tab('show');
				    	  $.ajax({
				    		  type:"post",
				    		  url:"../user/querytitle.action",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#titlecontent").append(data.content);
				    		  }
				    	  })
				    	  $.ajax({
				    		  type:"get",
				    		  url:"../user/querylosing.action",
				    		  dataType:"json",
				    		  success:function(data){
				    			  if(data.losinginfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.losinginfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
				    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.losinginfo[i].categoryName+'遗失，求助大家</td><td style="width: 40%;text-align: right;">'+
				    						  data.losinginfo[i].losingTime+'</td></tr>');
				    				  $("#losingingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#losingingpagecount").text(data.count);
				    			  
				    			  if(data.losinginfo.length==0){
				    				  $("#losingitem").append("暂时还没有人发帖");
				    			  }	 
				    		  },
				    		  error:function(){
				    			  $("#losingitem").append("暂时还没有人发帖");
				    		  }
				    	  });
				    	  $.ajax({
				    		  type:"get",
				    		  url:"../user/querypicking.action",
				    		  dataType:"json",
				    		  success:function(data){
				    			  var length;
				    			  if(data.pickInfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.pickInfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
				    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.pickInfo[i].categoryName+'找到，大家来领取</td><td style="width: 40%;text-align: right;">'+
				    						  data.pickInfo[i].pickerTime+'</td></tr>');
				    				  $("#findingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#findingpagecount").text(data.count);
				    			  if(data.pickInfo.length==0){
				    				  $("#findingitem").append("暂时还没有人发帖");
				    			  }
				    			  
				    		  },
				    		  error:function(){
				    			  $("#findingitem").append("暂时还没有人发帖");
				    		  }
				    	  });
				    	  //首页
				    	  $("#losingfirst").click(function(){
				    		  $.ajax({
			    				  type:"get",
					    		  url:"../user/querylosing.action?currentpage=0",
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#losingitem tr").remove();
					    			  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
					    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.losinginfo[i].categoryName+'遗失，求助大家</td><td style="width: 40%;text-align: right;">'+
					    						  data.losinginfo[i].losingTime+'</td></tr>');
					    				  $("#losingingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#losingingpagecount").text(data.count);
					    		  }
			    			  })
				    	  });
				    	  //上一页
				    	  $("#losingprev").click(function(){
				    		  //alert(123);
				    		  //当前页
				    		  var pagecurrent=$("#losingingpagevalue").text();
				    		  //总页数
				    		  var pagecount=$("#losingingpagecount").text();
				    		  if(pagecurrent==0){
				    			  alert("不好意思，已经是第一页了");
				    		  }
				    		  else{
				    			  $.ajax({
				    				  type:"get",
						    		  url:"../user/querylosing.action?currentpage="+(parseInt(pagecurrent)-1),
						    		  dataType:"json",
						    		  success:function(data){
						    			  $("#losingitem tr").remove();
						    			  if(data.losinginfo.length>=5){
						    				  length=5;
						    			  }else{
						    				  length=data.losinginfo.length;
						    			  }
						    			  for(var i=0;i<length;i++){
						    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
						    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
						    						  data.losinginfo[i].categoryName+'遗失，求助大家</td><td style="width: 40%;text-align: right;">'+
						    						  data.losinginfo[i].losingTime+'</td></tr>');
						    				  $("#losingingpagevalue").text(data.currentpage);
						    			  }
						    			  $("#losingingpagecount").text(data.count);
						    		  }
				    			  })
				    		  }
				    		 // 
				    	  });
				    	  //下一页
				    	  $("#losingnext").click(function(){
				    		  //当前页
				    		  var pagecurrent=$("#losingingpagevalue").text();
				    		  //总页数
				    		  var pagecount=$("#losingingpagecount").text();
				    		  if((parseInt(pagecurrent)+1)*5>=pagecount){
				    			  alert("不好意思，已经是最后一页了");
				    		  }else{
				    			  $.ajax({
				    				  type:"get",
						    		  url:"../user/querylosing.action?currentpage="+(parseInt(pagecurrent)+1),
						    		  dataType:"json",
						    		  success:function(data){
						    			  $("#losingitem tr").remove();
						    			  if(data.losinginfo.length>=5){
						    				  length=5;
						    			  }else{
						    				  length=data.losinginfo.length;
						    			  }
						    			  for(var i=0;i<length;i++){
						    				  
						    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
						    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
						    						  data.losinginfo[i].categoryName+'遗失，求助大家</td><td style="width: 40%;text-align: right;">'+
						    						  data.losinginfo[i].losingTime+'</td></tr>');
						    				  $("#losingingpagevalue").text(data.currentpage);
						    			  }
						    			  $("#losingingpagecount").text(data.count);
						    		  }
				    			  })

				    		  }
				    	  });
				    	  //最后一页
				    	  $("#losinglast").click(function(){
				    		  var last;
				    		  if(parseInt($("#losingingpagecount").text())%5!=0){
				    			  last=parseInt(parseInt($("#losingingpagecount").text())/5);
				    		  }else{
				    			  last=parseInt($("#losingingpagecount").text())/5-1;
				    		  }
				    		  $.ajax({
			    				  type:"get",
					    		  url:"../user/querylosing.action?currentpage="+last,
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#losingitem tr").remove();
					    			  if(data.losinginfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.losinginfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				 
					    				  $("#losingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="losinghelp(this)"><td style="display: none;" >'+
					    						  data.losinginfo[i].losingId+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.losinginfo[i].categoryName+'遗失，求助大家</td><td style="width: 40%;text-align: right;">'+
					    						  data.losinginfo[i].losingTime+'</td></tr>');
					    				  $("#losingingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#losingingpagecount").text(data.count);
					    		  }
			    			  })
				    	  });
				    	  
				    	 
				    	 
				      })
				      function losinghelp(e){
				    	  //alert($(e).children(":first").text());
				    	  var id=$(e).children(":first").text();
				    	  var categotyappend=$("#categotyappend").find("option:selected").val();
				    	  window.open("../user/ItemInfo.jsp?id="+id+"&type=0");
				      }
				      function findinghelp(e){
				    	  //alert($(e).children(":first").text());
				    	  var id=$(e).children(":first").text();
				    	  window.open("../user/ItemInfo.jsp?id="+id+"&type=1");
				      }
				      
				      $("#itemfirst").click(function(){
				    	  $.ajax({
				    		  type:"get",
				    		  url:"../user/querypicking.action?currentpage=0",
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#findingitem tr").remove();
				    			  var length;
				    			  if(data.pickInfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.pickInfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
				    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.pickInfo[i].categoryName+'找到，大家来领取</td><td style="width: 40%;text-align: right;">'+
				    						  data.pickInfo[i].pickerTime+'</td></tr>');
				    				  $("#findingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#findingpagecount").text(data.count);
				    		  }
				    	  });
				      });
				      
				      $("#itemprev").click(function(){
				    	  var pagecurrent=$("#findingpagevalue").text();
			    		  //总页数
			    		  var pagecount=$("#findingpagecount").text();
			    		  if(parseInt(pagecurrent)==0){
			    			  alert("不好意思，已经是第一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/querypicking.action?currentpage="+(parseInt(pagecurrent)-1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#findingitem tr").remove();
					    			  var length;
					    			  if(data.pickInfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.pickInfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
					    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.pickInfo[i].categoryName+'找到，大家来领取</td><td style="width: 40%;text-align: right;">'+
					    						  data.pickInfo[i].pickerTime+'</td></tr>');
					    				  $("#findingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#findingpagecount").text(data.count);
					    		  }
					    	  });
			    		  }
				    	 
				      });
				      
				      $("#itemnext").click(function(){
				    	  //当前页
			    		  var pagecurrent=$("#findingpagevalue").text();
				    	  //alert(pagecurrent);
			    		  //总页数
			    		  var pagecount=$("#findingpagecount").text();
			    		  //alert(pagecount);
			    		  if((parseInt(pagecurrent)+1)*5>=pagecount){
			    			  alert("不好意思，已经是最后一页了");
			    		  }else{
			    			  $.ajax({
			    				  type:"get",
					    		  url:"../user/querypicking.action?currentpage="+(parseInt(pagecurrent)+1),
					    		  dataType:"json",
					    		  success:function(data){
					    			  $("#findingitem tr").remove();
					    			  if(data.pickInfo.length>=5){
					    				  length=5;
					    			  }else{
					    				  length=data.pickInfo.length;
					    			  }
					    			  for(var i=0;i<length;i++){
					    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
					    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
					    						  data.pickInfo[i].categoryName+'找到，大家来领取</td><td style="width: 40%;text-align: right;">'+
					    						  data.pickInfo[i].pickerTime+'</td></tr>');
					    				  $("#findingpagevalue").text(data.currentpage);
					    			  }
					    			  $("#findingpagecount").text(data.count);
					    		  }
			    			  });
			    		  }
				      });
				      
				      $("#itemlast").click(function(){
				    	  var last;
			    		  if(parseInt($("#findingpagecount").text())%5!=0){
			    			  last=parseInt(parseInt($("#findingpagecount").text())/5);
			    		  }else{
			    			  last=parseInt($("#findingpagecount").text())/5-1;
			    		  }
			    		  $.ajax({
		    				  type:"get",
				    		  url:"../user/querypicking.action?currentpage="+last,
				    		  dataType:"json",
				    		  success:function(data){
				    			  $("#findingitem tr").remove();
				    			  if(data.pickInfo.length>=5){
				    				  length=5;
				    			  }else{
				    				  length=data.pickInfo.length;
				    			  }
				    			  for(var i=0;i<length;i++){
				    				 
				    				  $("#findingitem").append('<tr style="border-bottom: 1px dashed gray;" onclick="findinghelp(this)"><td style="display: none;" >'+
				    						  data.pickInfo[i].pickingID+'</td><td style="width: 60%;"><span class="glyphicon glyphicon-volume-up"></span>'+
				    						  data.pickInfo[i].categoryName+'找到，大家来领取</td><td style="width: 40%;text-align: right;">'+
				    						  data.pickInfo[i].pickerTime+'</td></tr>');
				    				  $("#findingpagevalue").text(data.currentpage);
				    			  }
				    			  $("#findingpagecount").text(data.count);
				    		  }
		    			  })
				      })
				
				</script>
</body>

</html>